﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PepsiCo.Common.Entities;
using Microsoft.SharePoint;
using T2V.SharePoint.Common.Utilities;
using T2V.SharePoint.Common.Utilities.Camlex;

namespace PepsiCo.Common.Services
{
    public class LinkService
    {
        public static List<LinkItem> GetLinks(SPList list, int itemCount, string pagingInfo, out SPListItemCollection collection)
        {
            CAMLListQuery<LinkItem> query = new CAMLListQuery<LinkItem>(list);

            string caml = string.Empty;
            caml = Camlex.Query()
                         .Where(x => x["IsActive"] == (DataTypes.Boolean)"1")
                         .OrderBy(x => x[SPBuiltInFieldId.Title] as Camlex.Asc)
                         .ToString();

            return query.ExecuteListQuery(caml, itemCount, pagingInfo, out collection);
        }
    }
}
